package com.sh.caryr.erp.entity.trade;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.sh.caryr.erp.entity.enums.ExpressType;
import com.sh.caryr.erp.entity.enums.ProductTypeEnum;
import com.sh.caryr.erp.util.DateUtils;
import com.sh.caryr.erp.util.ERPConstants;
import com.sh.caryr.erp.util.UtilityTool;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 交易子单表
 * </p>
 *
 * @author milkeeper
 * @since 2017-12-01
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("erp_trade_order")
public class TradeOrder implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 交易子单号
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    /**
     * 公司代码
     */
    private String coco;
    /**
     * 交易号
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long tradeId;
    /**
     * 平台交易号，线上订单：电商平台上生成的订单交易号
     */
    private String plantTxnId;
    /**
     * 店铺ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long shopId;
    /**
     * 交易订单状态，待付款0、待审核1、待分配快递2、快递单待打印3、发货单待打印4、包装待验货5、
     * 包裹待称重6、发货7、成功8、关闭10、作废11、挂起12、缺货13
     */
    private Integer status;
    /**
     * 是否加急，0：否，1：是
     */
    private Integer isUrgent;
    /**
     * 是否是第三方商品，0：否，1：是
     */
    private Integer isThirdOrder;
    /**
     * 实际付款金额
     */
    @Excel(name = "实际付款金额", isImportField = "true_st")
    private Float actualPaymentMoney;
    /**
     * 实际运费
     */
    private Float actualExpressMoney;
    /**
     * 付款时间
     */
    private Date payTime;
    /**
     * 下单时间
     */
    private Date orderTime;
    /**
     * 发货时间
     */
    private Date sendOutTime;
    /**
     * 仓库id
     */
    @Excel(name = "仓库编号")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long storageId;
    /**
     * 物流类型
     */
    private ExpressType expressType;
    /**
     * 快递公司
     */
    @Excel(name = "快递公司")
    private String expressName;
    /**
     * 快递运单号
     */
    @Excel(name = "快递单号")
    private String expressOrderId;
    /**
     * sku或者套件Id
     * Note: For excel: suffix = "x" is used to fix conversion issue of Formula to Long.
     */
    @Excel(name = "规格编码", isImportField = "true_st", suffix = "x")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long productSpecId;
    /**
     * 数量
     */

    @Excel(name = "数量", isImportField = "true_st")
    private Float productSpecAmount;

    @TableField(exist=false)
    private String extProductSpecId;

    @TableField(exist=false)
    private String extProductSpecName;

    /**
     * 商家编码
     */
    @Excel(name = "商家编码")
    private String code;
    /**
     * 商品名称
     */
    @Excel(name = "商品名称")
    private String name;

    /**
     * 单品 或 套件
     */
    @TableField(exist = false)
    @Excel(name = "商品类型")
    private String productTypeForExcel;
    /**
     * 类型，普通商品：0，含sku套件：1，不含sku套件：2
     */
    private ProductTypeEnum productType;
    /**
     * 客户备注
     */
    @Excel(name = "买家备注", isImportField = "true_st")
    private String customRemark;
    /**
     * 客户留言
     */
    @Excel(name = "买家留言", isImportField = "true_st")
    private String customNote;
    /**
     * 系统备注
     */
    @Excel(name = "系统备注", isImportField = "true_st")
    private String systemRemark;
    /**
     * Is Deleted
     */
    @Builder.Default
    private int isActive = ERPConstants.ENITYT_ACTIVE;
    /**
     * 更新日期
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtils.DATE_FORMAT_FULL)
    private Date updateAt;
    /**
     * 更新用户
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long updateBy;
    /**
     * 创建日期
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtils.DATE_FORMAT_FULL)
    private Date createAt;
    /**
     * 创建人
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long createBy;

    /**
     * 销售价
     */
    @TableField(exist = false)
    private Float salePrice;
}
